﻿using Quartz;
using WeskyQuantDemo.Models;

namespace WeskyQuantDemo.Services.Jobs
{
    [DisallowConcurrentExecution]
    public class GetCurrentPriceJob : IJob
    {
        private IQuantDataService _quantDataService;
        public GetCurrentPriceJob(IQuantDataService quantDataService)
        {
            _quantDataService = quantDataService;
        }

        public GetCurrentPriceJob()
        {

        }

        public async Task Execute(IJobExecutionContext context)
        {
            var apiUrl = "http://127.0.0.1:8080/api/public/stock_sz_a_spot_em";
            var apiUrlSH = "http://127.0.0.1:8080/api/public/stock_sh_a_spot_em";

            _quantDataService = Global.GlobalServiceProvider.GetService<IQuantDataService>();

            var result1 = await _quantDataService.GetStockInfosAsync<IEnumerable<StockCurrentInfo>>(apiUrl);
            var result2 = await _quantDataService.GetStockInfosAsync<IEnumerable<StockCurrentInfo>>(apiUrlSH);

            // 数据存储或者写入数据库或文件等，自行操作

        }

    }
}
